// -----------------------------------------------------------------------
//  <copyright file="IStateStore.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2023 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://www.dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2023-12-20 14:15</last-date>
// -----------------------------------------------------------------------

namespace DaprPlus.Domain.States;

/// <summary>
/// 定义状态存储功能
/// </summary>
public interface IStateStore
{
    /// <summary>
    /// 保存数据到状态存储
    /// </summary>
    /// <typeparam name="T">数据类型</typeparam>
    /// <param name="key">键</param>
    /// <param name="value">值</param>
    /// <param name="cancellationToken">取消令牌</param>
    /// <returns>保存任务</returns>
    Task SaveAsync<T>(string key, T value, CancellationToken cancellationToken = default);

    /// <summary>
    /// 从状态存储中获取数据
    /// </summary>
    /// <typeparam name="T">数据类型</typeparam>
    /// <param name="key">键</param>
    /// <param name="cancellationToken">取消令牌</param>
    /// <returns>获取任务</returns>
    Task GetAsync<T>(string key, CancellationToken cancellationToken = default);

    /// <summary>
    /// 从状态存储中删除数据
    /// </summary>
    /// <param name="key">键</param>
    /// <param name="cancellationToken">取消令牌</param>
    /// <returns>删除任务</returns>
    Task DeleteAsync(string key, CancellationToken cancellationToken = default);
}
